package inherit;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-05-18
 * Time: 14:38
 */
class Animal{
    public String name;
    public int age;

    public void eat(){
        System.out.println(name + "正在吃饭！");
    }

}
//一般继承不要超过3层
class Dog extends Animal{

    public void barks(){
        System.out.println(name + "汪！"+"年龄:"+age);
    }
}

class Cat extends Animal{
    public String name;
    public int age;

    public void barks(){
        System.out.println(name + "喵！");
    }
    public void catchMouse(){
        System.out.println(name + "正在抓老鼠！");
    }
}

public class Test {

    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.name = "旺财";
        dog.age = 10;
        dog.barks();
        dog.eat();
    }
}
